package idutil

import (
	"math/rand"
	"time"
)

const (
	Alphabet62 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	Alphabet36 = "abcdefghijklmnopqrstuvwxyz1234567890"
)

var letters = []rune(Alphabet62)

// GetInstanceID returns id format like: secret-2v69o5
func GetInstanceID(prefix string, len int) string {

	return prefix + GenerateStringID(len)
}

func GenerateStringID(n int) string {
	s := make([]rune, n)
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	rct := len(letters)
	for i := range s {
		s[i] = letters[r.Intn(rct)]
	}
	return string(s)
}
